unit ufrmAbertura;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, dxGDIPlusClasses, ExtCtrls, ComCtrls, AdvProgressBar;

type
  TfrmAbertura = class(TForm)
    img1: TImage;
    lbl1: TLabel;
    lbl2: TLabel;
    lblVersaoAtual: TLabel;
    lbl3: TLabel;
    lblStatus: TLabel;
    pnl1: TPanel;
    pbAbertura: TAdvProgressBar;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    function GetVersion(sFileName:string): string;
  end;

var
  frmAbertura: TfrmAbertura;

implementation

{$R *.dfm}

{ TfrmAbertura }

procedure TfrmAbertura.FormShow(Sender: TObject);
begin
  lblVersaoAtual.Caption := GetVersion(Application.ExeName);
end;

function TfrmAbertura.GetVersion(sFileName: string): string;
var
  VerInfoSize: DWORD;
  VerInfo: Pointer;
  VerValueSize: DWORD;
  VerValue: PVSFixedFileInfo;
  Dummy: DWORD;
begin
  VerInfoSize := GetFileVersionInfoSize(PChar(sFileName), Dummy);
  GetMem(VerInfo, VerInfoSize);
  GetFileVersionInfo(PChar(sFileName), 0, VerInfoSize, VerInfo);
  VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
  with VerValue^ do
  begin
    Result := IntToStr(dwFileVersionMS shr 16);
    Result := Result + '.' + IntToStr(dwFileVersionMS and $FFFF);
    Result := Result + '.' + IntToStr(dwFileVersionLS shr 16);
    Result := Result + '.' + IntToStr(dwFileVersionLS and $FFFF);
  end;
  FreeMem(VerInfo, VerInfoSize);
end;

end.
